<template>
    <div>
        <van-nav-bar
            title=""
            left-text="返回"
            left-arrow
            @click-left="onClickLeft"
        >
            <template #right>
                <van-icon @click="collection(1)" name="like-o" v-show="news.fcollection == 0"/>
                <van-icon @click="collection(0)" name="like" v-show="news.fcollection == 1"  color="#ee0a24"/>
            </template>
        </van-nav-bar>
        <p style="text-align:left;margin-left:10px" v-show="news.fcalalogname">检验项目</p>
        <van-cell-group v-show="news.fcalalogname">
            <van-cell >
                <template slot="title">
                    <div v-html="news.fcalalogname" class='celltitle'></div>
                </template>
            </van-cell>
        </van-cell-group>

         <p style="text-align:left;margin-left:10px" v-show="news.fhtmlcontent">检查内容</p>
        <van-cell-group v-show="news.fhtmlcontent">
            <van-cell >
                <template slot="title">
                    <div v-html="news.fhtmlcontent" class='celltitle'></div>
                </template>
            </van-cell>
        </van-cell-group>

         <p style="text-align:left;margin-left:10px" v-show="news.fhtmlremark">检查方法</p>
        <van-cell-group v-show="news.fhtmlremark">
            <van-cell >
                <template slot="title">
                    <div v-html="news.fhtmlremark" class='celltitle'></div>
                </template>
            </van-cell>
        </van-cell-group>

         <p style="text-align:left;margin-left:10px" v-show="news.fremark">参考规范</p>
         <van-cell-group v-show="news.fremark">
            <van-cell >
                <template slot="title">
                    <div v-html="news.fremark" class='celltitle'></div>
                </template>
            </van-cell>
        </van-cell-group>
    </div>
</template>

<script>
import { 
    NavBar
    ,Icon
    ,Cell
    ,CellGroup
    ,Toast
} from 'vant';
import {
    getdatabynewsid
    ,updatecolletion
} from '@/api/gov/regime';
export default {
    name: 'classDetail',
    components: {
        [Cell.name]:Cell,
        [CellGroup.name]:CellGroup,
        [NavBar.name]:NavBar,
        [Icon.name]:Icon,
        [Toast.name]:Icon,
    },
    data () {
        return {
            fid: '',
            news: {},
            optionMenu: [
                { label: '收藏', type: 'info', eventName: '' }
            ]
        }
    },
    created(){
        this.fid = this.$route.query.fid
        this.getData()
    },
    methods:{
        onClickLeft(){
            this.$router.go('-1')
        },
        getData () {
            getdatabynewsid({
                fid: this.fid,
                userid: '472a1e84dfcf4dce945bdcd3fe37304a'
            }).then(res => {
                console.log(res)
                this.news = res.map
            })
        },
        collection (state) {
            updatecolletion({
                fnewsid: this.fid,
                fstate: state,
                userid: '472a1e84dfcf4dce945bdcd3fe37304a'
            }).then(res => {
                if (res.isSuccess) {
                    Toast.success('操作成功！')
                    this.getData(1)
                } else {
                    Toast.fail( res.errMessage)
                }
            })
        }
    }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style>

</style>
